---@class SkillAiBean
SkillAiBean = ClientFight.CreateClass("SkillAiBean")
function SkillAiBean:ctor()
    ---@type table<SkillAiParam>
    self.aiParams = {}
end


--[[
* 技能设定的ai策略 以及他的参数
]]
function SkillAiBean:getParamValueByType(type)
    for k, aiParam in pairs(self.aiParams) do
        if (aiParam.type == type.type) then
            return aiParam.value;
        end
    end
    return nil;
end

--[[
* @param fighter
* @param target
* @param skill
* @return 0 成功通过 , 1=未通过,启用默认的, 2=直接跳过,选不到人就直接不选了
]]
function SkillAiBean:aiSelect(fighter, target, skill)
    local skillBean = skill.skillBean;
    local conditionType = skillBean.conditionType;
    local type = SkillAiConditionType.valueOf(conditionType);
    if (type == nil) then
        --目前只做单 参数的 选择
        return 0;
    end
    local param = self:getParamValueByType(type);
    if (param == nil) then
        return 0;
    end
    local result = type.action(fighter, target, skill, param);
    if (conditionType > 0 and not result) then
        return type == SkillAiConditionType.TARGET_APPOINT and 1 or 2;
    end
    if (conditionType < 0 and result) then
        return type == SkillAiConditionType.TARGET_APPOINT and 1 or 2;
    end
    return 0;
end